package component;

import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class AboutDialog extends JDialog {
	
	public static final int WIDTH = 320;
	public static final int HEIGHT= 180;
	public static final String HEADER = "About OMQ";
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public AboutDialog(Frame arg0) {
		super(arg0);
		init();
	}

	public AboutDialog(Frame arg0, boolean arg1) {
		super(arg0, arg1);
		init();
	}

	public AboutDialog(Frame arg0, String arg1) {
		super(arg0, arg1);
		init();
	}

	public AboutDialog(Frame arg0, String arg1, boolean arg2) {
		super(arg0, arg1, arg2);
		init();
	}

	public AboutDialog(Frame arg0, String arg1, boolean arg2,
			GraphicsConfiguration arg3) {
		super(arg0, arg1, arg2, arg3);
		init();
	}

	public AboutDialog(Dialog arg0) {
		super(arg0);
		init();
	}

	public AboutDialog(Dialog arg0, String arg1) {
		super(arg0, arg1);
		init();
	}

	public AboutDialog(Dialog arg0, String arg1, boolean arg2) {
		super(arg0, arg1, arg2);
		init();
	}

	public AboutDialog(Dialog arg0, String arg1, boolean arg2,
			GraphicsConfiguration arg3) {
		super(arg0, arg1, arg2, arg3);
		init();
	}
	
	private void init(){
		this.setLayout(new GridLayout(0,1));
		this.setSize(new Dimension(WIDTH,HEIGHT));
		this.setLocation(150,100);
		this.setBackground(Color.WHITE);
		this.setForeground(Color.WHITE);
		this.setTitle(HEADER);
		JLabel infoLbl = new JLabel("<html><body><center>Infrastructure version : 1.0.2<br> Client version : 1.0.6<br> Home page : <a href='http://www.onlinemq.com'>http://www.onlinemq.com</a>'</center></body></html>");
		infoLbl.setSize(new Dimension(WIDTH,HEIGHT));
		this.add(infoLbl);
		JPanel btnPanel = new JPanel();
		JButton button = new JButton("Close");
		button.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
		    	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		    	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		    	dispose(); 
		    }
		});
		button.setSize(new Dimension(50,20));
		btnPanel.add(button);
		this.add(btnPanel);
	}

}
